//
//  Swift_Head.swift
//  swift Demo
//
//  Created by Mac2 on 2017/8/22.
//  Copyright © 2017年 圣光大人. All rights reserved.
//

import Foundation
import UIKit

//MARK: 🐷 自定义打印格式 🐷
/**多参数*/
func ZMLog<T>(_ message : T, file : String = #file, lineNumber : Int = #line) {
    
    #if DEBUG
    let now = Date();
    let formatter = DateFormatter();
    formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
    let time = formatter.string(from: now);
    
    let fileName = (file as NSString).lastPathComponent.components(separatedBy: ".").first!
    print("[\(time) \(fileName):\(lineNumber)]👉 \(message)")

    #endif
}


func ZMImage(_ name : String!) -> UIImage!{
    
    let image = UIImage.init(named: name);
    //    if image != nil{
    return image;
    //    }else{
    ////        image =
    //
    //    }
    
}
func ZMHexColor(_ str_color : String) -> UIColor{
    
    return UIColor.hexStringToColor(hexString: str_color);
}

func transX(_ x : CGFloat) -> CGFloat{
    return ZMTool.transitionX(X: x);
}
func transY(_ y : CGFloat) -> CGFloat{
    return ZMTool.transitionY(Y: y);
}
func transW(_ x : CGFloat) -> CGFloat{
    return ZMTool.transitionX(X: x);
}
func transH(_ y : CGFloat) -> CGFloat{
    return ZMTool.transitionY(Y: y);
}
func distanceW(_ view : UIView ,_ placeW : CGFloat) -> CGFloat{
    return ZMTool.distanceW(origin: view, X: placeW);
}
func distanceH(_ view : UIView ,_ placeH : CGFloat) -> CGFloat{
    return ZMTool.distanceH(origin: view, Y: placeH);
}

/// 导航栏高度 适配
let NavBar_H:CGFloat = ISIPHONEX() ? 88:64

/// tababr高度
let Tabbar_H:CGFloat = ISIPHONEX() ? 34.0 + 49.0 : 49.0

///状态栏高度
let SafeTop_H:CGFloat = ISIPHONEX() ? 44.0 : 20.0

///屏幕宽
let KWIDTH:CGFloat = UIScreen.main.bounds.size.width

///屏幕高
let KHEIGHT:CGFloat = UIScreen.main.bounds.size.height

///iphoneX底部安全区
let SafeBottom_H:CGFloat = ISIPHONEX() ? 34.0 : 0.0

/// 是否是X
/// 是否是全面屏X
@inline(__always) func ISIPHONEX()->Bool{
    if #available(iOS 13.0, *) {
        let keyWindow = UIApplication.shared.connectedScenes
            .map({$0 as? UIWindowScene})
            .compactMap({$0})
            .first?.windows.first
        return (keyWindow?.windowScene?.statusBarManager?.statusBarFrame.height) == 44 ? true : false;
    }else{
        return (UIApplication.shared.statusBarFrame.height)  == 44 ? true : false;
    }
}
